/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('bdrc', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CheckRulesRequest {
  resourceArn?: string(name='ResourceArn', description='This parameter is required.', example='acs:ecs:123***890:cn-shanghai:instance/i-001***90'),
  ruleId?: string(name='RuleId', example='rule-000***dav'),
}

model CheckRulesResponseBody = {
  data?: {
    taskId?: string(name='TaskId', example='t-0000e4w0u1v592zdf6s7'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='700683DE-0154-56D4-8D76-3B7A2C2C7DF9'),
}

model CheckRulesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CheckRulesResponseBody(name='body'),
}

/**
 * @param request CheckRulesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CheckRulesResponse
 */
async function checkRulesWithOptions(request: CheckRulesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CheckRulesResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.resourceArn)) {
    body['ResourceArn'] = request.resourceArn;
  }
  if (!Util.isUnset(request.ruleId)) {
    body['RuleId'] = request.ruleId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CheckRules',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/rules/check`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request CheckRulesRequest
 * @return CheckRulesResponse
 */
async function checkRules(request: CheckRulesRequest): CheckRulesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return checkRulesWithOptions(request, headers, runtime);
}

model CloseBdrcServiceResponseBody = {
  requestId?: string(name='RequestId', example='663D8898-E0B5-5964-BF28-A191CE6A1825'),
}

model CloseBdrcServiceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CloseBdrcServiceResponseBody(name='body'),
}

/**
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CloseBdrcServiceResponse
 */
async function closeBdrcServiceWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): CloseBdrcServiceResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'CloseBdrcService',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/service/close`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @return CloseBdrcServiceResponse
 */
async function closeBdrcService(): CloseBdrcServiceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return closeBdrcServiceWithOptions(headers, runtime);
}

model DescribeCheckDetailsRequest {
  maxResults?: int32(name='MaxResults', example='10'),
  nextToken?: string(name='NextToken', example='cae**********699'),
  resourceArn?: string(name='ResourceArn', description='This parameter is required.', example='acs:ecs:123***890:cn-shanghai:instance/i-001***90'),
  ruleId?: string(name='RuleId', example='rule-000***dav'),
}

model DescribeCheckDetailsResponseBody = {
  data?: {
    content?: [ 
      {
        checkStatus?: string(name='CheckStatus', example='PASSED'),
        checkTime?: long(name='CheckTime', example='1701725715'),
        detail?: string(name='Detail', example='{"ecsAutoSnapshotPolicyIds":[],"hbrBackupPlans":[{"planId":"po-xxxxxxxx","sourceType":"UDM_ECS"}]}'),
        productType?: string(name='ProductType', example='ecs'),
        resourceArn?: string(name='ResourceArn', example='acs:ecs:123***890:cn-shanghai:instance/i-001***90'),
        resourceId?: string(name='ResourceId', example='i-xxxxxxxx'),
        resourceName?: string(name='ResourceName', example='test server'),
        resourceType?: string(name='ResourceType', example='ACS::ECS::Instance'),
        ruleId?: string(name='RuleId', example='rule-xxxxxxxx'),
        ruleTemplate?: string(name='RuleTemplate', example='ecs-backup'),
      }
    ](name='Content'),
    maxResults?: int32(name='MaxResults', example='10'),
    nextToken?: string(name='NextToken', example='CAESGgoSChAKDGNvbXBsZXRlVGltZRABCgQiAggAGAAiQAoJAOTzWWYAAAAACjMDLgAAADFTNzMyZDMwMzAzMDM4NzA3NTcwMzY2MjMwNzY2ODcyMzAzMTY2Nzg3ODY5MzY='),
    totalCount?: long(name='TotalCount', example='100'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='92793A50-0B97-59F1-BAEA-EAED83BA1998'),
}

model DescribeCheckDetailsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeCheckDetailsResponseBody(name='body'),
}

/**
 * @param request DescribeCheckDetailsRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeCheckDetailsResponse
 */
async function describeCheckDetailsWithOptions(request: DescribeCheckDetailsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeCheckDetailsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.resourceArn)) {
    query['ResourceArn'] = request.resourceArn;
  }
  if (!Util.isUnset(request.ruleId)) {
    query['RuleId'] = request.ruleId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeCheckDetails',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/check-details`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DescribeCheckDetailsRequest
 * @return DescribeCheckDetailsResponse
 */
async function describeCheckDetails(request: DescribeCheckDetailsRequest): DescribeCheckDetailsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeCheckDetailsWithOptions(request, headers, runtime);
}

model DescribeProductsResponseBody = {
  data?: {
    content?: [ 
      {
        checkFailedCount?: long(name='CheckFailedCount', example='1'),
        checkFailedResourceCount?: long(name='CheckFailedResourceCount', example='1'),
        disableCheckResourceCount?: long(name='DisableCheckResourceCount', example='1'),
        enableCheck?: boolean(name='EnableCheck', example='true'),
        productType?: string(name='ProductType', example='oss'),
        protectionScore?: int32(name='ProtectionScore', example='90'),
        protectionScoreDistribution?: [ 
          {
            count?: long(name='Count', example='5'),
            range?: {
              from?: int32(name='From', example='0'),
              to?: int32(name='To', example='60'),
            }(name='Range'),
          }
        ](name='ProtectionScoreDistribution'),
        protectionScoreUpdatedTime?: long(name='ProtectionScoreUpdatedTime', example='1726036498'),
        riskCount?: long(name='RiskCount', example='1'),
        riskyResourceCount?: long(name='RiskyResourceCount', example='1'),
        totalResourceCount?: long(name='TotalResourceCount', example='100'),
      }
    ](name='Content'),
    maxResults?: int32(name='MaxResults', example='10'),
    nextToken?: string(name='NextToken', example='b4fd3cffcacafd65e3818a0b9b2ff9a2'),
    totalCount?: long(name='TotalCount', example='50'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='30FB202A-1D22-5394-AB02-4477CDFCF51F'),
}

model DescribeProductsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeProductsResponseBody(name='body'),
}

/**
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeProductsResponse
 */
async function describeProductsWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): DescribeProductsResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DescribeProducts',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/products`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @return DescribeProductsResponse
 */
async function describeProducts(): DescribeProductsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeProductsWithOptions(headers, runtime);
}

model DescribeResourcesRequest {
  dataRedundancyType?: string(name='DataRedundancyType', example='LRS'),
  failedRuleTemplate?: string(name='FailedRuleTemplate', example='rule-000c***yc9'),
  maxResults?: int32(name='MaxResults', example='10'),
  nextToken?: string(name='NextToken', example='cae**********699'),
  resourceId?: string(name='ResourceId', example='i-0003***110'),
  resourceType?: string(name='ResourceType', example='ACS::ECS::Instance'),
  sortBy?: string(name='SortBy', example='protectionScore'),
  sortOrder?: string(name='SortOrder', example='ASC'),
  storageClass?: string(name='StorageClass', example='ARCHIVE'),
}

model DescribeResourcesResponseBody = {
  data?: {
    content?: [ 
      {
        archiveDataSize?: long(name='ArchiveDataSize', example='0'),
        checkFailedCount?: long(name='CheckFailedCount', example='0'),
        coldArchiveDataSize?: long(name='ColdArchiveDataSize', example='0'),
        createTime?: long(name='CreateTime', example='1697798340'),
        dataRedundancyType?: string(name='DataRedundancyType'),
        enableCheck?: boolean(name='EnableCheck', example='0'),
        iaDataSize?: long(name='IaDataSize', example='0'),
        productType?: string(name='ProductType', example='ecs'),
        protectionScore?: int32(name='ProtectionScore', example='0'),
        protectionScoreUpdatedTime?: long(name='ProtectionScoreUpdatedTime', example='0'),
        regionId?: string(name='RegionId', example='cn-hangzhou'),
        resourceArn?: string(name='ResourceArn', example='acs:ecs:cn-hangzhou:xxxxxxxx:instance/xxxxx'),
        resourceId?: string(name='ResourceId', example='i-xxxxxxxx'),
        resourceName?: string(name='ResourceName', example='test server'),
        resourceType?: string(name='ResourceType', example='ACS::ECS::Instance'),
        riskCount?: long(name='RiskCount', example='0'),
        standardDataSize?: long(name='StandardDataSize', example='0'),
        status?: string(name='Status', example='Running'),
        storageClass?: string(name='StorageClass'),
        totalDataSize?: long(name='TotalDataSize', example='0'),
        vSwitchId?: string(name='VSwitchId', description='vSwitch ID', example='vsw-xxxxxxxx'),
        vpcId?: string(name='VpcId', description='vpc ID', example='vpc-xxxxxxxx'),
        zoneId?: string(name='ZoneId', example='cn-hangzhou-i'),
      }
    ](name='Content'),
    maxResults?: int32(name='MaxResults', example='100'),
    nextToken?: string(name='NextToken', example='fb836242f4225fa0f0e0257362dfc6dd'),
    totalCount?: long(name='TotalCount', example='149'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='700683DE-0154-56D4-8D76-3B7A2C2C7DF9'),
}

model DescribeResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeResourcesResponseBody(name='body'),
}

/**
 * @param request DescribeResourcesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeResourcesResponse
 */
async function describeResourcesWithOptions(request: DescribeResourcesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeResourcesResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.dataRedundancyType)) {
    query['DataRedundancyType'] = request.dataRedundancyType;
  }
  if (!Util.isUnset(request.failedRuleTemplate)) {
    query['FailedRuleTemplate'] = request.failedRuleTemplate;
  }
  if (!Util.isUnset(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.resourceId)) {
    query['ResourceId'] = request.resourceId;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.sortBy)) {
    query['SortBy'] = request.sortBy;
  }
  if (!Util.isUnset(request.sortOrder)) {
    query['SortOrder'] = request.sortOrder;
  }
  if (!Util.isUnset(request.storageClass)) {
    query['StorageClass'] = request.storageClass;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeResources',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/resources`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DescribeResourcesRequest
 * @return DescribeResourcesResponse
 */
async function describeResources(request: DescribeResourcesRequest): DescribeResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeResourcesWithOptions(request, headers, runtime);
}

model DescribeRulesRequest {
  maxResults?: int32(name='MaxResults', example='10'),
  nextToken?: string(name='NextToken', example='cae**********699'),
  resourceType?: string(name='ResourceType', example='ACS::ECS::Instance'),
}

model DescribeRulesResponseBody = {
  data?: {
    content?: [ 
      {
        checkFailedResourceCount?: long(name='CheckFailedResourceCount', example='0'),
        checkStatus?: string(name='CheckStatus', example='PASSED'),
        checkTime?: long(name='CheckTime', example='1704157635'),
        productType?: string(name='ProductType', example='ecs'),
        resourceType?: string(name='ResourceType', example='ACS::ECS::Instance'),
        riskyResourceCount?: long(name='RiskyResourceCount', example='0'),
        ruleId?: string(name='RuleId', example='rule-bp11ggd8wr762'),
        ruleTemplate?: string(name='RuleTemplate', example='ecs-backup'),
        totalResourceCount?: long(name='TotalResourceCount', example='1'),
      }
    ](name='Content'),
    maxResults?: int32(name='MaxResults', example='10'),
    nextToken?: string(name='NextToken', example='0975951c75d7b41464c8d08ae17043ca'),
    totalCount?: long(name='TotalCount', example='42'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='86DEBAC9-AB6A-59AB-9E5C-A540E579ECC9'),
}

model DescribeRulesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeRulesResponseBody(name='body'),
}

/**
 * @param request DescribeRulesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeRulesResponse
 */
async function describeRulesWithOptions(request: DescribeRulesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeRulesResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeRules',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/rules`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DescribeRulesRequest
 * @return DescribeRulesResponse
 */
async function describeRules(request: DescribeRulesRequest): DescribeRulesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeRulesWithOptions(request, headers, runtime);
}

model DescribeTaskResponseBody = {
  data?: {
    completeTime?: long(name='CompleteTime', example='1724983927'),
    errorMessage?: string(name='ErrorMessage', example='too many requests.'),
    executionId?: string(name='ExecutionId'),
    expireTime?: long(name='ExpireTime', example='1719026680'),
    progress?: int32(name='Progress', example='100'),
    requestId?: string(name='RequestId', example='784076D6-BD6D-5564-9CEA-834EB11F0C62'),
    startTime?: long(name='StartTime', example='1724983927'),
    taskDescription?: string(name='TaskDescription'),
    taskDetail?: string(name='TaskDetail', example='{"resourceTypes":["ACS::ECS::Instance","ACS::OSS::Bucket","ACS::OTS::Instance","ACS::NAS::FileSystem"]}'),
    taskId?: string(name='TaskId', example='t-xxxxxxxx'),
    taskName?: string(name='TaskName', example='test5566'),
    taskPriority?: string(name='TaskPriority'),
    taskStatus?: string(name='TaskStatus', example='RUNNING'),
    taskType?: string(name='TaskType', example='UPDATE_RESOURCES'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='14DFF801-A4E3-5136-AAB8-7D246012CD7A'),
}

model DescribeTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeTaskResponseBody(name='body'),
}

/**
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeTaskResponse
 */
async function describeTaskWithOptions(TaskId: string, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeTaskResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DescribeTask',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/tasks/${OpenApiUtil.getEncodeParam(TaskId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @return DescribeTaskResponse
 */
async function describeTask(TaskId: string): DescribeTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeTaskWithOptions(TaskId, headers, runtime);
}

model DescribeTasksRequest {
  maxResults?: int32(name='MaxResults', example='10'),
  nextToken?: string(name='NextToken', example='cae**********699'),
  taskStatus?: string(name='TaskStatus', example='RUNNING'),
}

model DescribeTasksResponseBody = {
  data?: {
    content?: [ 
      {
        completeTime?: long(name='CompleteTime', example='1724983927'),
        errorMessage?: string(name='ErrorMessage', example='device not online'),
        executionId?: string(name='ExecutionId', example='empty'),
        expireTime?: long(name='ExpireTime', example='1724983927'),
        progress?: int32(name='Progress', example='100'),
        requestId?: string(name='RequestId', example='AE43C4CB-8074-5EBD-9806-8CA6D12800B1'),
        startTime?: long(name='StartTime', example='1724983927'),
        taskDescription?: string(name='TaskDescription', example='empty'),
        taskDetail?: string(name='TaskDetail', example='{"resourceTypes":["ACS::ECS::Instance","ACS::OSS::Bucket","ACS::OTS::Instance","ACS::NAS::FileSystem"]}'),
        taskId?: string(name='TaskId', example='t-0000e4w0u1v592zdf6s7'),
        taskName?: string(name='TaskName', example='empty'),
        taskPriority?: string(name='TaskPriority', example='HIGH'),
        taskStatus?: string(name='TaskStatus', example='RUNNING'),
        taskType?: string(name='TaskType', example='UPDATE_RESOURCES'),
      }
    ](name='Content'),
    maxResults?: int32(name='MaxResults', example='10'),
    nextToken?: string(name='NextToken', example='f4b8c2504545a3b41af5e75147d17d12e3818a0b9b2ff9a2'),
    totalCount?: long(name='TotalCount', example='100'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='AE43C4CB-8074-5EBD-9806-8CA6D12800B1'),
}

model DescribeTasksResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeTasksResponseBody(name='body'),
}

/**
 * @param request DescribeTasksRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeTasksResponse
 */
async function describeTasksWithOptions(request: DescribeTasksRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeTasksResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['MaxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['NextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.taskStatus)) {
    query['TaskStatus'] = request.taskStatus;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeTasks',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/tasks`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DescribeTasksRequest
 * @return DescribeTasksResponse
 */
async function describeTasks(request: DescribeTasksRequest): DescribeTasksResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeTasksWithOptions(request, headers, runtime);
}

model DescribeTopRiskyResourcesRequest {
  resourceType?: string(name='ResourceType', example='ACS::ECS::Instance'),
}

model DescribeTopRiskyResourcesResponseBody = {
  data?: {
    content?: [ 
      {
        archiveDataSize?: long(name='ArchiveDataSize', example='0'),
        checkFailedCount?: long(name='CheckFailedCount', example='0'),
        coldArchiveDataSize?: long(name='ColdArchiveDataSize', example='0'),
        createTime?: long(name='CreateTime', example='1697798340'),
        dataRedundancyType?: string(name='DataRedundancyType'),
        enableCheck?: boolean(name='EnableCheck', example='true'),
        iaDataSize?: long(name='IaDataSize', example='0'),
        productType?: string(name='ProductType', example='ecs'),
        protectionScore?: int32(name='ProtectionScore', example='90'),
        protectionScoreUpdatedTime?: long(name='ProtectionScoreUpdatedTime', example='1726036498'),
        regionId?: string(name='RegionId', example='cn-hangzhou'),
        resourceArn?: string(name='ResourceArn', example='acs:ecs:cn-hangzhou:xxxxxxxx:instance/xxxxx'),
        resourceId?: string(name='ResourceId', example='i-xxxxxxxx'),
        resourceName?: string(name='ResourceName', example='test-server'),
        resourceType?: string(name='ResourceType', example='ACS::ECS::Instance'),
        riskCount?: long(name='RiskCount', example='0'),
        standardDataSize?: long(name='StandardDataSize', example='0'),
        status?: string(name='Status', example='Running'),
        storageClass?: string(name='StorageClass'),
        totalDataSize?: long(name='TotalDataSize', example='0'),
        vSwitchId?: string(name='VSwitchId', description='vSwitch ID', example='vsw-xxxxxxxx'),
        vpcId?: string(name='VpcId', description='vpc ID', example='vpc-xxxxxxxx'),
        zoneId?: string(name='ZoneId', example='cn-hangzhou-j'),
      }
    ](name='Content'),
    maxResults?: int32(name='MaxResults', example='10'),
    nextToken?: string(name='NextToken', example='e557bc9a65fe22cb5e2a3b240f06b0de'),
    totalCount?: long(name='TotalCount', example='10'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='34081B20-C4C0-514F-93F6-8EEC3D1A587E'),
}

model DescribeTopRiskyResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeTopRiskyResourcesResponseBody(name='body'),
}

/**
 * @param request DescribeTopRiskyResourcesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeTopRiskyResourcesResponse
 */
async function describeTopRiskyResourcesWithOptions(request: DescribeTopRiskyResourcesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DescribeTopRiskyResourcesResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.resourceType)) {
    query['ResourceType'] = request.resourceType;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeTopRiskyResources',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/resources/top-risky`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DescribeTopRiskyResourcesRequest
 * @return DescribeTopRiskyResourcesResponse
 */
async function describeTopRiskyResources(request: DescribeTopRiskyResourcesRequest): DescribeTopRiskyResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return describeTopRiskyResourcesWithOptions(request, headers, runtime);
}

model DisableCheckProductRequest {
  productType?: string(name='ProductType', description='This parameter is required.', example='ecs'),
}

model DisableCheckProductResponseBody = {
  requestId?: string(name='RequestId', example='89E3CBB7-16F3-52AE-BD32-31A43A2A807F'),
}

model DisableCheckProductResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DisableCheckProductResponseBody(name='body'),
}

/**
 * @param request DisableCheckProductRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DisableCheckProductResponse
 */
async function disableCheckProductWithOptions(request: DisableCheckProductRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DisableCheckProductResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.productType)) {
    body['ProductType'] = request.productType;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DisableCheckProduct',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/products/disable-check`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DisableCheckProductRequest
 * @return DisableCheckProductResponse
 */
async function disableCheckProduct(request: DisableCheckProductRequest): DisableCheckProductResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return disableCheckProductWithOptions(request, headers, runtime);
}

model DisableCheckResourceRequest {
  resourceArn?: string(name='ResourceArn', description='This parameter is required.', example='acs:ecs:123***890:cn-shanghai:instance/i-001***90'),
}

model DisableCheckResourceResponseBody = {
  requestId?: string(name='RequestId', example='86DEBAC9-AB6A-59AB-9E5C-A540E579ECC9'),
}

model DisableCheckResourceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DisableCheckResourceResponseBody(name='body'),
}

/**
 * @param request DisableCheckResourceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DisableCheckResourceResponse
 */
async function disableCheckResourceWithOptions(request: DisableCheckResourceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DisableCheckResourceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.resourceArn)) {
    body['ResourceArn'] = request.resourceArn;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DisableCheckResource',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/resources/disable-check`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request DisableCheckResourceRequest
 * @return DisableCheckResourceResponse
 */
async function disableCheckResource(request: DisableCheckResourceRequest): DisableCheckResourceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return disableCheckResourceWithOptions(request, headers, runtime);
}

model EnableCheckProductRequest {
  productType?: string(name='ProductType', description='This parameter is required.', example='ecs'),
}

model EnableCheckProductResponseBody = {
  requestId?: string(name='RequestId', example='8724BC18-904D-5A0D-BFF4-F0554F0037E7'),
}

model EnableCheckProductResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: EnableCheckProductResponseBody(name='body'),
}

/**
 * @param request EnableCheckProductRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return EnableCheckProductResponse
 */
async function enableCheckProductWithOptions(request: EnableCheckProductRequest, headers: map[string]string, runtime: Util.RuntimeOptions): EnableCheckProductResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.productType)) {
    body['ProductType'] = request.productType;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'EnableCheckProduct',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/products/enable-check`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request EnableCheckProductRequest
 * @return EnableCheckProductResponse
 */
async function enableCheckProduct(request: EnableCheckProductRequest): EnableCheckProductResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return enableCheckProductWithOptions(request, headers, runtime);
}

model EnableCheckResourceRequest {
  resourceArn?: string(name='ResourceArn', description='This parameter is required.', example='acs:ecs:123***890:cn-shanghai:instance/i-001***90'),
}

model EnableCheckResourceResponseBody = {
  requestId?: string(name='RequestId', example='E583A0FF-803C-51C4-9AC9-E029471ACD6A'),
}

model EnableCheckResourceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: EnableCheckResourceResponseBody(name='body'),
}

/**
 * @param request EnableCheckResourceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return EnableCheckResourceResponse
 */
async function enableCheckResourceWithOptions(request: EnableCheckResourceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): EnableCheckResourceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.resourceArn)) {
    body['ResourceArn'] = request.resourceArn;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'EnableCheckResource',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/resources/enable-check`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request EnableCheckResourceRequest
 * @return EnableCheckResourceResponse
 */
async function enableCheckResource(request: EnableCheckResourceRequest): EnableCheckResourceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return enableCheckResourceWithOptions(request, headers, runtime);
}

model GetBdrcServiceResponseBody = {
  data?: {
    openTime?: long(name='OpenTime', example='1726169608'),
    protectionScoreUpdatedTime?: long(name='ProtectionScoreUpdatedTime', example='1726169608'),
    serviceInitializeStatus?: string(name='ServiceInitializeStatus', example='SUCCESS'),
    serviceStatus?: string(name='ServiceStatus', example='OPENED'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='5748C531-80B1-5C31-8421-63A1830B9E48'),
}

model GetBdrcServiceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetBdrcServiceResponseBody(name='body'),
}

/**
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetBdrcServiceResponse
 */
async function getBdrcServiceWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): GetBdrcServiceResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetBdrcService',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/service`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @return GetBdrcServiceResponse
 */
async function getBdrcService(): GetBdrcServiceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getBdrcServiceWithOptions(headers, runtime);
}

model OpenBdrcServiceResponseBody = {
  requestId?: string(name='RequestId', example='86DEBAC9-AB6A-59AB-9E5C-A540E579ECC9'),
}

model OpenBdrcServiceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: OpenBdrcServiceResponseBody(name='body'),
}

/**
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return OpenBdrcServiceResponse
 */
async function openBdrcServiceWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): OpenBdrcServiceResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'OpenBdrcService',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/service/open`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @return OpenBdrcServiceResponse
 */
async function openBdrcService(): OpenBdrcServiceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return openBdrcServiceWithOptions(headers, runtime);
}

model UpdateResourcesRequest {
  resourceType?: string(name='ResourceType', example='ACS::ECS::Instance'),
}

model UpdateResourcesResponseBody = {
  data?: {
    taskId?: string(name='TaskId', example='t-bp1ewftyzmeg3bl4dtd2'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='5B2F09BF-CEBD-5A7E-AC01-E7F86169A5E5'),
}

model UpdateResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateResourcesResponseBody(name='body'),
}

/**
 * @param request UpdateResourcesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateResourcesResponse
 */
async function updateResourcesWithOptions(request: UpdateResourcesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateResourcesResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.resourceType)) {
    body['ResourceType'] = request.resourceType;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateResources',
    version = '2023-08-08',
    protocol = 'HTTPS',
    pathname = `/api/v1/resources/update`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request UpdateResourcesRequest
 * @return UpdateResourcesResponse
 */
async function updateResources(request: UpdateResourcesRequest): UpdateResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateResourcesWithOptions(request, headers, runtime);
}

